import org.hibernate.Session;
import org.hibernate.Transaction;

public class TheApp {
	public static void main(String[] args) {
		TheApp tst = new TheApp();
		tst.addUser("Saranga");
	}

	private void addUser(String firstName) {
		Transaction trns = null;
		Session session = HibernateUtil.getSessionFactory().openSession();
		try {
			trns = session.beginTransaction();
			Member user = new Member();
			user.setName(firstName);
			session.save(user);
			session.getTransaction().commit();
		} catch (RuntimeException e) {
			if (trns != null) {
				trns.rollback();
			}
			e.printStackTrace();
		} finally {
			session.flush();
			session.close();
		}
	}
}
